<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ATM取款机</title>
</head>
<body>
    <script>
        //初始金额
        let money = 100;
        //循环操作
        while(true){
            //选择
            let choose = +prompt(`
            请输入你的选择：
                1.存钱
                2.取钱
                3.查询
                4.退出
            `)
            //如果你选择的是4那么就结束循环
            if(choose === 4){
                break;
            }
            switch(choose){
                case 1:
                    //存钱
                    let saveMoney = +prompt('请输入你要存钱的金额：');
                    money += saveMoney;
                    break;
                case 2:
                    //取钱
                    let withdrawMoney = +prompt('请输入你要取款的金额：');
                    let mid = money - withdrawMoney;
                    if(mid >= 0){
                        money -= mid;
                        alert('取款成功');
                    } else{
                        alert('余额不足！！！');
                    }
                    break;
                case 3:
                    alert(`您的余额为：${money}`);
                    break;
                default:
                    alert('异常操作！！！');
                    break;
                    //switch中的break仅仅是跳出switch而无法跳出while
                    //因此跳出循环的语句要写在switch外面哦
            }
        }
    </script>
</body>
</html>